<{include file="Public/top.html" }>
	</head>
	<body>
		<div id="warpper">
            <div class="content">
                <div class="location">满员抽奖</div>
                <{include file="./fullNav.html" }>
                <div class="topic">活动信息</div>
                <div class="form-box border0 border-box">
                    <form class="ui-form" id="addManagerForm">
                        <div class="ui-form-item inline-block">
                            <input type="hidden" value="<{$obj.id|default:0}>" name="id">
                            <dl>
                                <label class="ui-label">对应期号</label>
                                <select class="ui-select" name="period">
                                    <{html_options options=$period selected=$obj.period}>
                                </select>
                            </dl>
                        	<dl>
                                <label class="ui-label">标题</label>
                                <input type="text" class="ui-text" placeholder="吃吃吃就知道吃" name="title" value="<{$obj.title}>" required/>
                            </dl>
                        	<dl>
                                <label class="ui-label">会员等级</label>
                                <select class="ui-select" name="userLevelRequire">
                                    <{html_options options=$userLevelRequire selected=$obj.userLevelRequire}>
                                </select>
                                <div style="float: right;">(0级表示没有等级要求)</div>
                            </dl>
                        	<dl>
                                <label class="ui-label">所需积分</label>
                                <input type="text" class="ui-text" placeholder="134" name="points" value="<{$obj.points}>" onkeyup="this.value=this.value.replace(/[^\d]/g,'') " onafterpaste="this.value=this.value.replace(/[^\d]/g,'') " required/>
                            </dl>
                        	<dl>
                                <label class="ui-label">原价</label>
                                <input type="text" class="ui-text" placeholder="2000.00" name="originalPrice" value="<{$obj.originalPrice}>" onkeyup="this.value=this.value.replace(/[^\d.]/g,'') " onafterpaste="this.value=this.value.replace(/[^\d.]/g,'') " required/>
                            </dl>
                            <dl>
                                <label class="ui-label">满员要求(人次)</label>
                                <input type="text" class="ui-text" placeholder="30" name="joinPeopleNum" id="fullNumber" value="<{$obj.fullNumber}>" onkeyup="this.value=this.value.replace(/[^\d]/g,'') " onafterpaste="this.value=this.value.replace(/[^\d]/g,'') " required/>
                            </dl>
                        	<dl>
                                <label class="ui-label">奖品数量</label>
                                <input type="text" class="ui-text" placeholder="30" name="prizeNum" id="prizeNum" value="<{$obj.prizeNum}>" onkeyup="this.value=this.value.replace(/[^\d]/g,'') "  onafterpaste="this.value=this.value.replace(/[^\d]/g,'') " required/>
                            </dl>
                            <dl>
                                <label class="ui-label">每人允许投入份数</label>
                                <input type="text" name="quota" class="ui-text" placeholder="1" value="<{$obj.quota}>" onkeyup="this.value=this.value.replace(/[^\d]/g,'') "  onafterpaste="this.value=this.value.replace(/[^\d]/g,'') " required/>
                            </dl>
                        	<dl>
                                <label class="ui-label">奖品类型</label>
                                <select class="ui-select" name="prizeType">
                                    <{html_options options=$prizeType selected=$obj.prizeType}>
                                </select>    
                            </dl>
                        	<dl>
                                <label class="ui-label">显示开始时间</label>
                                <input id="d411" class="ui-select" type="text"  name="beginShowTimestamp" value="<{$obj.beginShowTimestamp|date_format:'%Y-%m-%d %T'}>" required/>
                            </dl>
                        	<dl>
                                <label class="ui-label">活动开始时间</label>
                                <input id="d412" class="ui-select" type="text" name="beginTime" value="<{$obj.beginTime|date_format:'%Y-%m-%d %T'}>" required/>
                            </dl>
                        	<dl>
                                <label class="ui-label">活动结束时间</label>
                                <input id="d413" class="ui-select" type="text" name="endTime" value="<{$obj.endTime|date_format:'%Y-%m-%d %T'}>" required/>
                            </dl>
                        </div>
                        <div class="ui-form-item2 inline-block" style="vertical-align:top;">
                            <label class="ui-label mll00">列表图片</label>
                            <span class="picture_box picture_245">
                                <div class="a-imgBox" id="imgBox" <{if $obj.listPic}> style="display:block;" <{else}> style="display:none;" <{/if}>>
                                    <a href="javascript:void(0);" class="a-close" onclick="removeElement('imgBox','listPic')"></a>
                                    <img src="<{$obj.listPic}>" width="245" height="169" id="listImg"/>
                                    <input type="hidden" name="listPic" id="listPic" value="<{$obj.listPic}>" />
                                </div>
                                <div style="margin-top:40px;">
                                    <a href="javascript:void(0);" class="a-upload">
                                        <input type="file" name="file" id="addListPic">
                                    </a>
                                    <i>上传图片</i>
                                    <i>640*350</i>
                                </div>
                            </span>

                        </div>
                        <div class="ui-form-item">
                            <label class="ui-label">详情图片</label>
                            <ul class="Carousel_img">
                                <{foreach from=$marquee item=item}>
                                    <li>
                                        <input type="hidden" name="marquee[]" value="<{$item}>">
                                        <p><img src="<{$item}>" /><a class="delete" href="javascript:void (0);" onclick="delMarqueePic(this);">删除图片</a></p>
                                    </li>
                            	<{/foreach}>

                            	<li id="add"><a href="javascript:;"><input type="file" id="newPic" name="file" style="opacity: 0;width:100%;height:100%">&nbsp;&nbsp;</a></li>
                            </ul>
                        </div>
                        <div class="reply_box">
                            <label class="ui-label">活动详情</label>
                            <textarea id="editor" name="content" style="width:98%;height:400px;margin-top:10px"><{$obj.content}></textarea>

                        </div>

                    <div class="integral_btn-group">
                        <input type="submit" value="提交" class="ui-button" id="btn"/>
                        <input type="submit" value="清空" class="ui-button fade-o-butn"/>
                    </div>
                    </form>
                </div>
            </div>
		</div>

        <{include file="Public/foot.html" }>
        <{include file="Public/ueditor.html" }>
        <script>
            datePickter('d411');
            datePickter('d412','d413');
            var edit = "<{U('fullEdit')}>";
            function addMarquePic(val){
                var cloneObj='<li><input type="hidden" name="marquee[]" value="'+val+'"><p><img src="'+val+'" /><a class="delete" href="javascript:void(0);" onclick="delMarqueePic(this);">删除图片</a></p></li>';
                $('#add').before(cloneObj);
            }

            function delMarqueePic(obj){
                $(obj).parent().parent().remove();
            }
            function removeElement(id,src)
            {
                document.getElementById(id).style.display="none";
                //删除图片
                $("#"+src).val('');
            }


            var $listPic=$("#addListPic");
            $listPic.AjaxFileUpload({
                action: './api.php?m=Api&c=index&a=ajaxUpload&from=IMG_POINT_LOTTERY_ABOUT',
                onSubmit: function () {
                    console.log("开始上传");
                    layer.msg("开始上传");
                },
                onComplete: function (filename, response) {
                    if(parseInt(response.id)>0){
                        console.log("上传成功");
                        layer.msg("上传成功");
                        $('#listPic').val(response.msg);
                        $('#listImg').attr('src',response.msg);
                        $('#imgBox').css('display','block');
                    }else{
                        console.log(response.msg);
                    }
                }
            });

            var $file=$("#newPic");
            $file.AjaxFileUpload({
                action: './api.php?m=Api&c=index&a=ajaxUpload&from=IMG_POINT_LOTTERY_ABOUT',
                onSubmit: function () {
                    console.log("开始上传");
                    layer.msg("开始上传");
                },
                onComplete: function (filename, response) {
                    if(parseInt(response.id)>0){
                        console.log("上传成功");
                        layer.msg("上传成功");
                        addMarquePic(response.msg);
                    }else{
                        console.log(response.msg);
                    }
                    //$hidden.attr('val', response.msg);
                }
            });

            $("#btn").click(function(){
                if(!$("#listImg").attr('src')){
                    layer.msg("请选择列表图片");
                    return false;
                }
                if(UE.getEditor('editor').hasContents()==false){
                    layer.msg("请输入活动详情");
                    return false;
                }
                if($("#prizeNum").val()<=0){
                    layer.msg("奖品数量不能小于1");
                    return false;
                }
                if($("#fullNumber").val() <= 0 ){
                    layer.msg("满员人数不能小于1，请重新输入");
                    return false;
                }
                var param = $("#addManagerForm").serialize();
                $.post("<{U('fullUpdate')}>",param,function(data){
                    if(data.status==0){
                        layer.msg(data.msg);
                        location.href = edit+'&id='+data.id;
                    } else layer.msg(data.msg);
                });
            });


        </script>
	</body>
</html>